package views
{
	import flash.events.KeyboardEvent;
	import flash.events.LocationChangeEvent;
	import flash.geom.Rectangle;
	import flash.media.StageWebView;
	import flash.ui.Keyboard;
	
	import inerface.IHelp;
	
	import main.ViewSubBase;
	
	import panel.help.HelpPanel;
	
	public class HelpView extends ViewSubBase
	{
		private var _panel:IHelp;
		private var _webView:StageWebView;
		public function HelpView()
		{
			super();
		}
		
		public override function show():void
		{
			  render();
		}
		
		protected override function render():void
		{
			if(!_panel)
			{
				_panel = new HelpPanel();
				_panel.init(this.layout.stage,this.resourceLoader,this.lang,this.data.uri);
			}
			
			var dataList:Array = [
				{desc:"荣成交通",func:view.traffic.show},
				{desc:"旅游准备",func:view.ready.show},
				{desc:"荣成旅游官网",func:openWeb}
			];
				_panel.show(dataList);
				this.addView(_panel);
		}
		
		private function openWeb():void
		{
			if(!_webView) 
			{
		    _webView = new StageWebView();
			_webView.stage = this.layout.stage;
			_webView.viewPort = new Rectangle(0,0,this.layout.stage.stageWidth,this.layout.stage.stageHeight);
			_webView.loadURL("http://www.rongcheng.gov.cn/col/col28/index.html");
			this.layout.stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDownHandler);
//			_webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE,htmlPageLocationChangeHandler);
			}
		}
		
		protected function onKeyDownHandler(event:KeyboardEvent):void
		{
			if(event.keyCode == Keyboard.BACK)
			{
				event.preventDefault();
				event.stopPropagation();
				if(_webView)
				{
					_webView.stage = null;
				}
			}
		}		
		
	}
}